<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>退货订单</title>
<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
<!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
	<section class="content-header">
	<h1>退货订单</h1>
	<ol class="breadcrumb">
		<li><a href="${ctx }/home.jsp"><i class="fa fa-home"></i>首页</a></li>
		<li><a href="#">退货管理</a></li>
		<li class="active"><a href="#">历史退货单</a></li>
	</ol>
	</section>

	<section class="content">
        <div class="box box-success">
            <div class="box-body">
                <div class="form-inline">
					<div class="form-group form-group-xs">
						退货单号： <input class="form-control" type="text" id="retCode"	name="retCode" placeholder="退货单号" />
					</div>
					<div class="form-group form-group-xs">
						医疗机构： <input class="form-control" type="text" id="hospName"	name="hospName" placeholder="医疗机构" />
					</div>
<div class="form-group form-group-xs">
					退货日期： <input class="form-control" type="text"  name="submitStartDatetime" id="submitStartDatetime"
						dateFmt="yyyy-MM-dd" onFocus="var endDate=$dp.$('submitEndDatetime');WdatePicker({maxDate:'#F{$dp.$D(\'submitEndDatetime\')}'})" />
				
					<label>-</label>&nbsp;&nbsp;<input class="form-control" type="text" name="submitEndDatetime" id ="submitEndDatetime"
						dateFmt="yyyy-MM-dd" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'submitStartDatetime\')}'})" />
				</div>
				
				<div class="form-group form-group-xs">
					确认日期： <input class="form-control" type="text"  name="confirmBeginTime" id="confirmBeginTime"
						dateFmt="yyyy-MM-dd" onFocus="var endDate=$dp.$('confirmEndTime');WdatePicker({maxDate:'#F{$dp.$D(\'confirmEndTime\')}'})" />
				
					<label>-</label>&nbsp;&nbsp;<input class="form-control" type="text" name="confirmEndTime" id ="confirmEndTime"
						dateFmt="yyyy-MM-dd" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'confirmBeginTime\')}'})" />
				</div>
					<button type="button" onclick="gridSerch();" class="btn btn-success btn-sm">查询</button>
                </div>
            </div>
        </div>


        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
        <div class=" box box-warning bottongroup">
        </div>
    </section>
	<%@ include file="/WEB-INF/component/commonJS.jsp"%>
	<script type="text/javascript">
		$(function() {
			var date = new Date();
        date.setMonth(date.getMonth() - 1);
        $('#submitStartDatetime').val(date.format("yyyy-MM-dd"));
        $('#submitEndDatetime').val(new Date().format("yyyy-MM-dd"));
			$('#confirmBeginTime').val(date.format("yyyy-MM-dd"));
        $('#confirmEndTime').val(new Date().format("yyyy-MM-dd"));
			$("#gridlist").jqGrid({
						url : "${ctx}/purReturnOldOrder/getReturnOldOrderByDelDataList.html",
						mtype : "POST",
						datatype : "json",
						postData:{
							"beginTime":$.trim($('#submitStartDatetime').val()),
							"endTime":$.trim($('#submitEndDatetime').val()),
							"confirmBeginTime":$.trim($('#confirmBeginTime').val()),
							"confirmEndTime":$.trim($('#confirmEndTime').val())
						},
						autowidth : true,
						shrinkToFit: false,
						height : 270,
						colNames: [ '退货单号',  '医疗机构','退货条目', '退货金额','退货人','退货时间','状态','确认人','确认时间', '操作'],
		                colModel: [
							
							{ name: 'retCode', width: 180 , align:"center" ,sortable: false},
		                    { name: 'hospName', width: 180, align:"left" ,sortable: false,
								 formatter:function(cellvalue, options,row) {
									 return "<a href=\"javascript:$.HN.dialog.opendialog('"+cellvalue+"','"+cellvalue+"','${ctx}/stdHospInfo/hospInfoDetail.html?hospId="+row.hospId+"','800px','400px',function operResult(val){return operResult;})\">"+cellvalue+"</a>";
					     		}},
		                    { name: 'retCount', width: 80 , align:"center",sortable: false },
		                    { name: 'retMoney', width: 80 , align:"right",sortable: false },
		                    { name: 'submitUser', width: 150 , align:"center" ,sortable: false},
		                    { name: 'submitTime', width: 150 , align:"center" ,sortable: false},
		                    { name: 'status', width: 80 , align:"center" ,sortable: false},
		                    { name: 'confirmUser', width: 150 , align:"center" ,sortable: false},
		                    { name: 'confirmTime', width: 150 , align:"center" ,sortable: false},
		                    { name: 'oper', width: 150 , align:"center",sortable: false }
		                ], 
						rowNum : 20,
						rowList : [ 10, 20, 50, 100 ],
						rownumbers : true,
						pager: "#gridpage",
		                //multiselect: true, 
		                viewrecords: true,
		                gridComplete: function(){
		            		var ids = jQuery("#gridlist").jqGrid('getDataIDs');
		            		for(var i=0;i < ids.length;i++){
		            			var id = ids[i];
		            			var rowdata = $("#gridlist").jqGrid('getRowData', id);
		            			a = "<a href='${ctx}/purReturnOrder/toHospReturnInfoDetail.html?retCode="+rowdata.retCode+"'>详情</a>";
		            			jQuery("#gridlist").jqGrid('setRowData',ids[i],{oper:a});
		            		}	
		            	},
		            	
		                caption: "退货订单列表",
		                jsonReader: {
		                    repeatitems: false,
		                    id: "ids"
		                }
		            });
			$("#gridlist").jqGrid('navGrid', '#gridpage', {add : false,edit : false,del : false,search : false,refresh : false});
			$(window).trigger("resize");
		});

		//查询
        function gridSerch() {
        	var retCode = $.trim($("#retCode").val());
        	var hospName = $.trim($("#hospName").val());
    		$("#gridlist").jqGrid('setGridParam',{  
    	        datatype:'json',
    	        postData:{
    	        		"retCode":retCode,
    	        		"hospName":hospName,
    	        		"beginTime":$.trim($('#submitStartDatetime').val()),
							"endTime":$.trim($('#submitEndDatetime').val()),
							"confirmBeginTime":$.trim($('#confirmBeginTime').val()),
							"confirmEndTime":$.trim($('#confirmEndTime').val())},
    	        		page:1
    	    }).trigger("reloadGrid"); //重新载入  
    	}
		
      
        
      //回调
		 function operResult(val){
	        	var strs = new Array();
	            strs = val.split("|$");
	            
	            	if (val.length>0) {
						$('#'+strs[0]).val(strs[2]);
					}
					if (val.length>0) {
						$('#'+strs[1]).html(strs[3]);
					}
	        }
		
		
		
	</script>
</body>
</html>